﻿<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>学习会管理系统V3.0</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" href="./favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./static/css/font.css">
    <link rel="stylesheet" href="./static/css/weadmin.css">
    <script src="./lib/layui/layui.js" charset="utf-8"></script>
</head>

<body class="login-bg">
    <div class="hds" >
        <div class="hds-l"><span>机车乘务员学习会管理系统</span></div>
        <div class="hds-r"></div>
    </div>  
    <div class="loginhd">
        <div class="login">
            <div method="POST" class="layui-form">
                <div>
                    <div class="il"><img src="static/images/icon1.png" /></div>
                    <div class="ir"> <input name="userid" id="userid" placeholder="工号" type="text" lay-verify="required" class="layui-input"></div>
                </div>
                <hr class="hr15">
                <hr class="hr15">
                <hr class="hr15">
                <div>
                    <div class="il"><img src="static/images/icon2.png" /></div>
                    <div class="ir"> <input name="password" id="password" lay-verify="required" placeholder="密码" type="password" class="layui-input"></div>
                </div>
                <hr class="hr15">
                <hr class="hr15">
                <hr class="hr15">
                <div class="dlogin" lay-submit lay-filter="login" id="login"><img src="static/images/btn.png" /></div>
            </div>
        </div>
    </div>
    <div class="bots"><a>中国铁路济南局集团有限公司济南机务段</a></div>
    <script type="text/javascript">
        layui.use(['form', 'jquery'], function () {
            var form = layui.form
                , $ = layui.jquery;
            sessionStorage.removeItem("menu");

            //ajax设置
            $.support.cors = true;
            //监听提交
            form.on('submit(login)', function (data) {
                layer.load();

                var postdata = { 'userid': $("#userid").val().trim(), 'password': $("#password").val().trim() };
                $.ajax({
                    url: ApiUrl + "Login",
                    type: 'post',
                    dataType: 'json',
                    cache: false,
                    data: postdata,
                    success: function (data) {
                        if (data.StatusCode == 200 && data.Count != 0) {
                            var storage = window.localStorage;
                            var authInfo = {
                                UserId: $("#userid").val().trim(),
                                UserName: data.Data.split('|')[0],
                                SignToken: data.Data.split('|')[1],
                            };
                            storage.setItem("authInfo", JSON.stringify(authInfo));
                            location.href = './Manager.html';
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    },
                    error: function (XMLHttpRequest, textStatus) {
                        layer.msg("请求服务器出错，请检查网络！");
                    },
                    complete: function (XMLHttpRequest, textStatus) {
                        layer.closeAll('loading');
                        if (textStatus == 'timeout') {
                            layer.msg("请求超时，请检查网络！");
                        }
                    }
                });
                return false;
            });
            //输入框的值改变时触发
            $("#userid").on("keydown", function (e) {
                //获取input输入的值
                console.log(e.delegateTarget.value);
                if (e.which == 13)
                    $("#password").focus();
            });
            //输入框的值改变时触发
            $("#password").on("keydown", function (e) {
                //获取input输入的值 
                if (e.which == 13) {
                    $("#login").click();
                }
            });
        });
    </script>
</body>
</html>